from django.utils.translation import ugettext_lazy as _
from utils.menu import item, register_locmenu as register_menu

#------------------------------------------Appear Everywhere----------------------------
# Load this to the context of the corresponding menu template through a custom simple tag.
# Access menus through a custom tag, which takes the menu name as the first argument,
# current item index as an optional argument (no longer) and with the rest of the arguments similar 
# as the ones in the url tag. The menu loaded to the context will be an iterator of 
# (title, href) tuples with a 'current' attribute indicating the current item index.

#XX use classes instead?

register_menu("polls-main",
    (item('index',      _('Home'),             'polls-index'),
     item('create_f',   _('Create New Poll'),  'polls-create_f'),
     item('settings_f', _('Settings'),         'polls-settings_f'),
    ),
    None
)


#------------------------------------------Appear in index------------------------------

register_menu("polls-order_by",
    (#item(name, view, args, kwars, query)
     item('pub_date',   _('Publication Date'), query=(('o', 'pub_date'),)),
     item('votes',      _('Votes'),            query=(('o', 'votes'),)),
     item('last_vote',  _('Last Vote Date'),   query=(('o', 'last_vote'),)),
     item('contentious',_('Contentiousness'),  query=(('o', 'contentious'),)),
    ),
    #Used above when a parameter is missing (or always in query),
    #the values indicate keyword parameters that must be past to the menu tag
    item(query=(('p', 'page'),))#,
    #(
    #item(...)
    #...
    #)
    #item(...)
)

#XX pagination = ? possibly an iterator yielding appropriate page numbers

